<template>
	<view>
	<!-- 	<u-navbar
			:safeAreaInsetTop="true"
			title="验收记录"
			:fixed="true"
			:placeholder="true"
			left-text="返回"
			rightIcon="map"
			@rightClick="rightClick"
			@leftClick="goback"
		></u-navbar> -->
		<u-collapse :value="[]">
			<u-collapse-item name="1" title="工程信息" icon="https://cdn.uviewui.com/uview/example/cell.png">
		
		<buildinfo :buildid='buildid'></buildinfo>
		</u-collapse-item></u-collapse>
		<u-button class="custom-style" @click="openpage" type="success" loadingText="加载中" size="normal"
			icon="weixin-fill" v-if="user.Roles.indexOf('管理员') > -1 || user.Roles.indexOf('项目经理') > -1">添加工程验收记录</u-button>
			
		<!-- <u-search placeholder="请输入关键字" v-model="keyword"></u-search> -->
		<!-- <u-search v-model="keyword" :show-action="false" @change="getlist" placeholder="请输入关键字"></u-search> -->
		<u--text type="primary" text="验收记录:" ></u--text>		
		<u-empty v-if="isempty">
		</u-empty>
		<u-list @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in buildlist" :key="index">
				<u-cell :title="(index+1)+'、验收人'+':'+item.CreatorName+ ' '+item.CreateTime" isLink @click="openpage" :name="item.Id"
					icon="https://cdn.uviewui.com/uview/example/toast.png">
				</u-cell>
			</u-list-item>
		</u-list>

	</view>
</template>

<script>
	import {
		getbuildfinishlist
	} from '@/common/api.js'
	import buildinfo from "./c_buildinfo.vue"
	export default {
		components: {
		  buildinfo
		},
		data() {
			return {
				buildlist: [],
				keyword: "",
				buildid:null,
				id:null,
				user: JSON.parse(uni.getStorageSync("$userinfo")),
				isempty:false,
			}
		},
		onLoad(option) {
			this.buildid=option.buildid
			this.id=option.id
			this.getlist()
		},
		methods: {
			rightClick()
			{
				uni.navigateTo({
					url: "map?buildid="+this.buildid
				})
			},
			goback()
			{
				uni.navigateBack({
					delta: 1
				});
			},
			openpage(e) {
				if (e) {
					
					uni.navigateTo({
						url: "buildFinishView?id="+e.name
					})
				} else {
					uni.navigateTo({
						url: "buildFinishEdit?buildid="+this.buildid
					})
				}
			},
			getlist() {
				// let querytype = this.$route.query.querytype
				let para = {
					Parameters: [],
					orderBys:["CreateTime desc"]
				}
				para.Parameters.push({
					FieldName: "BuildId",
					ConditionalType: "Equal",
					FieldValue: this.buildid
				})


				// if (querytype == "日志") {


				// }
				getbuildfinishlist(para).then(res => {
					this.buildlist = res.data
					this.isempty=(res.data.length==0)
				})
			},
			},
	}
</script>

<style>
	.custom-style {}
</style>
